import {Component, OnInit} from '@angular/core';
import {OriginalData} from "./original-data";
import {ResponseUtil} from "../../../util/response-util";
import {MsgResult} from "../../../models/msg-result";
import {MsgConstants} from "../../../constants/constants";
import {OneDialogService} from "../../../widgets/one-dialog/one-dialog.service";
import {OriginalDataService} from "./original-data.service";
import {Path} from "../../../portal/admin/admin-breadcrumb/breadcrumb";
import {PageSubject} from "../../../util/page-subject";
import {TableUtil} from "../../../util/table-util";

declare var $;

@Component({
  selector: 'app-original-data',
  templateUrl: 'original-data.component.html'
})
export class OriginalDataComponent implements OnInit {

  origin: OriginalData;

  monitorCode: string;

  snCodes: string;

  activeStatu: string = "small";

  constructor(private originalDataService: OriginalDataService,
              private responseUtil: ResponseUtil,
              private tableUtil: TableUtil,
              private dialogService: OneDialogService,
              private pageSubject: PageSubject,) {
    this.origin = new OriginalData();
  }

  ngOnInit() {
    this.pushPage();
    this.initConfig();
    this.initOriginFormData();
  }


  /**
   *  生成面包屑
   */
  private pushPage() {
    let path = new Path("数据表查询", null);
    this.pageSubject.pushPage("设备原始数据", "", path);
  }

  //初始化日期组件
  private initConfig() {
    $(".form_datetime").datetimepicker(
      {
        format: 'yyyy-mm-dd hh:ii',
        language: 'zh-CN',
        initialDate: new Date(),
        autoclose: true,
        todayBtn: true
      });

    $("#endTime").val(this.dateFormat(new Date(), "yyyy-MM-dd hh:mm"));
    let day1 = new Date();
    day1.setTime(day1.getTime() - 60 * 60 * 1000);
    $("#startTime").val(this.dateFormat(day1, "yyyy-MM-dd hh:mm"));
  }

  /**
   *  时间格式
   * @param d
   * @param fmt
   * @returns {any}
   */
  private dateFormat(d, fmt) { //author: meizz
    let o = {
      "M+": d.getMonth() + 1, //月份
      "d+": d.getDate(), //日
      "h+": d.getHours(), //小时
      "m+": d.getMinutes(), //分
      "s+": d.getSeconds(), //秒
      "q+": Math.floor((d.getMonth() + 3) / 3), //季度
      "S": d.getMilliseconds() //毫秒
    };
    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (d.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (let k in o)
      if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
  }

  search() {

    this.snCodes = $("#snCodes").val();
    //扬尘功能
    if (this.monitorCode == "256") {

      if (!!this.snCodes) {
        this.monitorCode = "256";
        this.commonMethod(this.monitorCode);
      } else {
        this.snCodes = "A609060001";
        this.monitorCode = "256";
        this.commonMethod(this.monitorCode);
      }
    }

    //微型空气站
    if (this.monitorCode == "257") {
      if (!!this.snCodes) {
        this.monitorCode = "257";
        this.commonMethod(this.monitorCode);
      } else {
        this.snCodes = "B329091017";
        this.monitorCode = "257";
        this.commonMethod(this.monitorCode);
      }
    }

    //VOC功能
    if (this.monitorCode == "258") {
      if (!!this.snCodes) {
        this.monitorCode = "258";
        this.commonMethod(this.monitorCode);
      } else {
        this.snCodes = "A721501015";
        this.monitorCode = "258";
        this.commonMethod(this.monitorCode);
      }
    }

    //油烟功能
    if (this.monitorCode == "101") {
      if (!!this.snCodes) {
        this.monitorCode = "101";
        this.commonMethod(this.monitorCode);
      } else {
        // this.seleteLampblack();
        this.snCodes = "0A001E5B";
        this.monitorCode = "101";
        this.commonMethod(this.monitorCode);
      }
    }

    //水功能
    if (this.monitorCode == "259") {
      if (!!this.snCodes) {
        this.monitorCode = "259";
        this.commonMethod(this.monitorCode);
      } else {
        this.snCodes = "0A001E5B";
        this.monitorCode = "259";
        this.commonMethod(this.monitorCode);
      }
    }

    //土壤功能
    if (this.monitorCode == "260") {
      if (!!this.snCodes) {
        this.monitorCode = "260";
        this.commonMethod(this.monitorCode);
      } else {
        this.snCodes = "0A001E5B";
        this.monitorCode = "260";
        this.commonMethod(this.monitorCode);
      }
    }


  }

  /**
   * 初始化微型空气站数据
   * 1.根据设备类型查询微型空气站数据；
   */
  initOriginFormData() {
    this.activeStatu = "small";
    this.monitorCode = "257";
    this.snCodes = "B329091017";
    this.commonMethod(this.monitorCode);
  }


  /**
   * 扬尘功能
   * 1.根据设备类型查询扬尘数据；
   */
  seleteDust() {
    this.activeStatu = "dust";
    this.monitorCode = "256";
    this.snCodes = "A609";
    this.commonMethod(this.monitorCode);
  }

  /**
   * 油烟功能
   * 1.根据设备类型查询油烟数据；
   */
  seleteLampblack() {
    this.activeStatu = "lampblack";
    this.monitorCode = "101";
    this.snCodes = "0A00";
    this.commonMethod(this.monitorCode);
  }

  /**
   * VOC功能
   * 1.根据设备类型查询VOC数据；
   */
  seleteVoc() {
    this.activeStatu = "voc";
    this.monitorCode = "258";
    this.snCodes = "A6918";
    this.commonMethod(this.monitorCode);
  }

  /**
   * 水功能
   * 1.根据设备类型查询水质数据；
   */
  activeWater() {
    this.activeStatu = "water";
    this.monitorCode = "259";
    this.snCodes = "A6918";
    this.commonMethod(this.monitorCode);
  }

  /**
   * 土壤功能
   * 1.根据设备类型查询土壤数据；
   */
  activeSoil() {
    this.activeStatu = "soil";
    this.monitorCode = "260";
    this.snCodes = "A6918";
    this.commonMethod(this.monitorCode);
  }


  /**
   * 查询原始数据；
   * 1.根据设备编码，时间查询；
   * 2.根据不同的设备类型编码，查询不同设备数据；
   * @param monitorCode ：设备类型编码
   */
  private commonMethod(monitorCode: string) {
    //  {"snCodes":"B329091017","startTime":"2017-08-11 09:04","endTime":"2017-08-11 10:04"}
    this.origin.snCodes = this.snCodes;
    this.origin.startTime = $("#startTime").val();
    this.origin.endTime = $("#endTime").val();
    this.origin.monitorCode = monitorCode;
    this.originalDataService.findScCollectDataList(this.origin).subscribe(
      result => this.responseUtil.success(result, this.generateFormData),
      message => this.responseUtil.error(message)
    );
  }

  /**
   * 处理查询数据
   * @param result ：返回数据
   */
  private generateFormData = (result: MsgResult) => {
    if (result && result.code == MsgConstants.MSG_CODE_OK) {
      //扬尘功能
      if (this.monitorCode == "256") {
        this.dustDataForm(result.data);
      }
      //微型空气站
      if (this.monitorCode == "257") {
        this.airStandDataForm(result.data);
      }
      //VOC功能
      if (this.monitorCode == "258") {
        this.vocDataForm(result.data);

      }
      //油烟功能
      if (this.monitorCode == "101") {
        this.lampblackDataForm(result.data);
      }
      //水质功能
      if (this.monitorCode == "259") {
        this.waterDataForm(result.data);
      }
      //土壤功能
      if (this.monitorCode == "260") {
        this.soilDataForm(result.data);
      }
    }
    if (result && result.code != MsgConstants.MSG_CODE_OK) {
      this.dialogService.info(result.message);
    }
  }

  /**
   * 表格化扬尘数据
   * @param dustDatas
   */
  private dustDataForm(dustDatas) {
    $(".one-table-area").html('<table id="one_table_monitor" style="width: 100%;"></table>');
    $('#one_table_monitor').bootstrapTable({
      columns: [
        [
          {
            field: 'SNCODE',
            title: '设备编号',
            valign: "middle",
          },
          {
            field: 'MONITORTIME',
            title: '监测时间',
            valign: "middle",
            align: "left",
            halign: "center"
          },
          {
            field: 'MONITORDATA.PM10',
            title: 'PM10',
            align: "right",
            halign: "center"
          }, {
          field: 'MONITORDATA.PM25',
          title: 'PM25',
          align: "right",
          halign: "center"
        }, {
          field: 'MONITORDATA.CTPM10',
          title: 'CTPM10',
          align: "right",
          halign: "center",visible: false
        }, {
          field: 'MONITORDATA.CTPM25',
          title: 'CTPM25',
          align: "right",
          halign: "center",visible: false
        }, {
          field: 'MONITORDATA.TEMP',
          title: '温度',
          align: "right",
          halign: "center"
        }, {
          field: 'MONITORDATA.HUM',
          title: '湿度',
          align: "right",
          halign: "center"
        }, {
          field: 'MONITORDATA.WD',
          title: '风向',
          align: "right",
          halign: "center"
        }, {
          field: 'MONITORDATA.WS',
          title: '风速',
          align: "right",
          halign: "center"
        }, {
          field: 'MONITORDATA.NOISE',
          title: '噪声',
          align: "right",
          halign: "center",visible: false
        }, {
          field: 'MONITORDATA.PRESSURE',
          title: '气压',
          align: "right",
          halign: "center",visible: false
        },
          {
            field: 'T5M',
            title: 'T5M',
            valign: "middle",
            align: "left",
            halign: "center", visible: false
          },
          {
            field: 'DATASOURCE',
            title: '数据来源',
            valign: "middle",
            align: "left",
            halign: "center",
            visible: false
          }, {
          field: 'CREATETIME',
          title: '创建时间',
          valign: "middle",
          align: "left",
          halign: "center"

        },
         {
          field: 'T1D',
          title: 'T1D',
          valign: "middle",
          align: "left",
          halign: "center",
          visible: false
        }, {
          field: 'CLIENTIPPORT',
          title: 'CLIENTIPPORT',
          valign: "middle",
          align: "left",
          halign: "center",
          visible: false
        },{
          field: 'SERVERIPPORT',
          title: '服务端地址',
          valign: "middle",
          visible: false
        }
        ]
      ],
      data: dustDatas,
      pagination: true,
      paginationLoop: false,
      striped: true,
      paginationPreText: "上一页",
      paginationNextText: "下一页",
      undefinedText: "-",
      showColumns: true,
      showExport: true,
      exportDataType: 'all', //导出类型
      buttonsAlign: "right",  //按钮位置
      exportTypes: ['excel'],  //导出文件类型
      exportOptions: {
        ignoreColumn: [0],  //根据索引忽[0,1,2]略某一列的导出数据
        fileName: '化扬尘数据报表',  //保存文件名称设置
        worksheetName: 'sheet1',  //表格工作区名称
        tableName: '化扬尘数据报表',
        excelstyles: ['background-color', 'color', 'font-size', 'font-weight'],
      },
      showRefresh: true,
      height: 711,
      toolbar: ".one-btn-crud",
      showPaginationSwitch: true,
      pageSize: 15,
      pageList: [10, 15, 20]
    });

  }

  /**
   * 规范微型空气站(小型站)数据
   * @param datas
   * @constructor
   */
  private airStandDataForm(airStandDatas) {
    $(".one-table-area").html('<table id="one_table_monitor"></table>');
    $('#one_table_monitor').bootstrapTable({
      columns: [
        [
          {
            field: 'SNCODE',
            title: '设备编号',
            valign: "middle",
            formatter: this.tableUtil.showToolTip
          }, {
          field: 'MONITORTIME',
          title: '监测时间',
          valign: "middle",
          align: "left",
          halign: "center"
        }, {
          field: 'MONITORDATA.PM10',
          title: 'PM10',
          align: "right",
          halign: "center"
        }, {
          field: 'MONITORDATA.PM25',
          title: 'PM25',
          align: "right",
          halign: "center"
        }, {
          field: 'MONITORDATA.ADSO2',
          title: 'ADSO2',
          align: "right",
          halign: "center"
        }, {
          field: 'MONITORDATA.ADNO2',
          title: 'ADNO2',
          align: "right",
          halign: "center"
        }, {
          field: 'MONITORDATA.ADCO',
          title: 'ADCO',
          align: "right",
          halign: "center"
        }, {
          field: 'MONITORDATA.ADO3',
          title: 'ADO3',
          align: "right",
          halign: "center"
        }, {
          field: 'MONITORDATA.TEMP',
          title: '温度',
          align: "right",
          halign: "center"
        }, {
          field: 'MONITORDATA.HUM',
          title: '湿度',
          align: "right",
          halign: "center"
        },
          {field: 'MONITORDATA.WD', title: '风向', align: "right", halign: "center" },
          {field: 'MONITORDATA.WS', title: '风速', align: "right", halign: "center"},
          {field: 'MONITORDATA.PRESSURE', title: '气压', align: "right", halign: "center", visible: false},
          { field: 'CALCULFLAG', title: 'CALCULFLAG',  valign: "middle", align: "left", halign: "center", visible: false },
          { field: 'T1H', title: 'T1H', valign: "middle", align: "left", halign: "center", visible: false },
          {field: 'T5M', title: 'T5M', valign: "middle", align: "left", halign: "center", visible: false},
          { field: 'CLIENTIPPORT', title: 'CLIENTIPPORT', valign: "middle", align: "left", halign: "center", visible: false ,formatter: this.tableUtil.showToolTip},
          {field: 'MONITORDATA.SO2', title: 'SO2', align: "right", halign: "center", visible: false},
          {field: 'MONITORDATA.NO2', title: 'NO2', align: "right", halign: "center", visible: false},
          {field: 'MONITORDATA.CO', title: 'CO', align: "right", halign: "center", visible: false},
          {field: 'MONITORDATA.O3', title: 'O3', align: "right", halign: "center", visible: false},
          {field: 'MONITORDATA.CTPM10', title: 'CTPM10', align: "right", halign: "center", visible: false},
          {field: 'MONITORDATA.CTPM25', title: 'CTPM25', align: "right", halign: "center", visible: false},
          { field: 'MONITORDATA.CTSO2', title: 'CTSO2', align: "right",  halign: "center", visible: false },
          { field: 'MONITORDATA.CTNO2', title: 'CTNO2',  align: "right", halign: "center", visible: false },
          {
          field: 'MONITORDATA.CTCO',
          title: 'CTCO',
          align: "right",
          halign: "center",
          visible: false
        }, {
          field: 'MONITORDATA.CTO3',
          title: 'CTO3',
          align: "right",
          halign: "center",
          visible: false
        },
          {
            field: 'DATASOURCE',
            title: '数据来源',
            valign: "middle",
            align: "left",
            halign: "center",
            visible: false
          },
          {
            field: 'SERVERIPPORT',
            title: '服务端地址',
            valign: "middle",
            align: "left",
            halign: "center",
            visible: false
          }, {
          field: 'EWLNG',
          title: '东/西经',
          valign: "middle",
          align: "left",
          halign: "center",
          visible: false
        },
          {
            field: 'LONGITUDE',
            title: '经度',
            valign: "middle",
            align: "left",
            halign: "center",
            visible: false
          },
          {
            field: 'NSLAT',
            title: '南/北纬',
            valign: "middle",
            align: "left",
            halign: "center",
            visible: false
          },
          {
            field: 'LATITUDE',
            title: '纬度',
            valign: "middle",
            align: "left",
            halign: "center",
            visible: false
          },
          {
            field: 'ALTITUDE',
            title: '海拔',
            valign: "middle",
            align: "left",
            halign: "center",
            visible: false
          }, {
          field: 'CREATETIME',
          title: '创建时间',
          valign: "middle",
          align: "left",
          halign: "center",
          visible: false
        }
        ]
      ],
      data: airStandDatas,

      pagination: true,
      paginationLoop: false,
      striped: true,
      paginationPreText: "上一页",
      paginationNextText: "下一页",
      undefinedText: "-",
      showColumns: true,
      showExport: true,
      exportDataType: 'all', //导出类型
      buttonsAlign: "right",  //按钮位置
      exportTypes: ['excel'],  //导出文件类型
      exportOptions: {
        ignoreColumn: [0],  //根据索引忽[0,1,2]略某一列的导出数据
        fileName: '微型空气站(小型站)数据报表',  //保存文件名称设置
        worksheetName: 'sheet1',  //表格工作区名称
        tableName: '微型空气站(小型站)数据报表',
        excelstyles: ['background-color', 'color', 'font-size', 'font-weight'],
      },
      showRefresh: true,
      height: 711,
      toolbar: ".one-btn-crud",
      showPaginationSwitch: true,
      pageSize: 15,
      pageList: [10, 15, 20]
    });

  }

  /**
   * 表格化VOC数据
   * @param vocDatas
   */
  private vocDataForm(vocDatas) {
    $(".one-table-area").html('<table id="one_table_monitor"></table>');
    $('#one_table_monitor').bootstrapTable({
      columns: [
        [
          {
            field: 'SNCODE',
            title: '设备编号',
            valign: "middle",
          },
          {
            field: 'MONITORTIME',
            title: '监测时间',
            valign: "middle",
            align: "left",
            halign: "center"
          },{
          field: 'MONITORDATA.ADTVOC',
          title: 'ADTVOC',
          align: "right",
          halign: "center"
        }, {
          field: 'MONITORDATA.TVOCs',
          title: 'TVOCs',
          align: "right",
          halign: "center"
        }, {
          field: 'MONITORDATA.TEMP',
          title: '温度',
          align: "right",
          halign: "center"
        }, {
          field: 'MONITORDATA.HUM',
          title: '湿度',
          align: "right",
          halign: "center"
        }, {
          field: 'MONITORDATA.WD',
          title: '风向',
          align: "right",
          halign: "center"
        }, {
          field: 'MONITORDATA.WS',
          title: '风速',
          align: "right",
          halign: "center"
        },
          {
            field: 'MONITORDATA.ADNH3',
            title: 'ADNH3',
            align: "right",
            halign: "center",
            visible: false
          }, {
          field: 'MONITORDATA.NH3',
          title: 'NH3',
          align: "right",
          halign: "center",
          visible: false
        }, {
          field: 'MONITORDATA.ADCL2',
          title: 'ADCL2',
          align: "right",
          halign: "center",
          visible: false
        }, {
          field: 'MONITORDATA.CL2',
          title: 'CL2',
          align: "right",
          halign: "center",
          visible: false
        }, {
          field: 'MONITORDATA.ADHCL',
          title: 'ADHCL',
          align: "right",
          halign: "center",
          visible: false
        }, {
          field: 'MONITORDATA.HCL',
          title: 'HCL',
          align: "right",
          halign: "center",
          visible: false
        }, {
          field: 'MONITORDATA.ADH2S',
          title: 'ADH2S',
          align: "right",
          halign: "center",
          visible: false
        }, {
          field: 'MONITORDATA.H2S',
          title: 'H2S',
          align: "right",
          halign: "center",
          visible: false
        }, {
          field: 'MONITORDATA.ADSO2',
          title: 'ADSO2',
          align: "right",
          halign: "center",
          visible: false
        }, {
          field: 'MONITORDATA.SO2',
          title: 'SO2',
          align: "right",
          halign: "center",
          visible: false
        },  {
          field: 'DATASOURCE',
          title: '数据来源',
          valign: "middle",
          align: "left",
          halign: "center",
          visible: false
        }, {
          field: 'CREATETIME',
          title: '创建时间',
          valign: "middle",
          align: "left",
          halign: "center"
        },
        ]
      ],
      data: vocDatas,
      pagination: true,
      paginationLoop: false,
      striped: true,
      paginationPreText: "上一页",
      paginationNextText: "下一页",
      undefinedText: "-",
      showColumns: true,
      showExport: true,
      exportDataType: 'all', //导出类型
      buttonsAlign: "right",  //按钮位置
      exportTypes: ['excel'],  //导出文件类型
      exportOptions: {
        ignoreColumn: [0],  //根据索引忽[0,1,2]略某一列的导出数据
        fileName: '表格化VOC数据报表',  //保存文件名称设置
        worksheetName: 'sheet1',  //表格工作区名称
        tableName: '表格化VOC数据报表',
        excelstyles: ['background-color', 'color', 'font-size', 'font-weight'],
      },
      showRefresh: true,
      height: 711,
      toolbar: ".one-btn-crud",
      showPaginationSwitch: true,
      pageSize: 15,
      pageList: [10, 15, 20]
    });

  }

  /**
   * 表格化油烟数据
   * @param lampblackDatas
   */
  private lampblackDataForm(lampblackDatas) {
    $(".one-table-area").html('<table id="one_table_monitor"></table>');
    $('#one_table_monitor').bootstrapTable({
      columns: [
        [
          {
            field: 'SNCODE',
            title: '设备编号',
            valign: "middle"
          },
          {
            field: 'MONITORTIME',
            title: '监测时间',
            valign: "middle",
            align: "left",
            halign: "center"
          },
          {
            field: 'DATASOURCE',
            title: '数据来源',
            valign: "middle",
            align: "left",
            halign: "center",
            visible: false
          }, {
          field: 'PROBE.VOCs',
          title: 'VOC浓度',
          align: "right",
          halign: "center"
        }, {
          field: 'PROBE.TEMP',
          title: '温度',
          align: "right",
          halign: "center"
        }, {
          field: 'PROBE.HUM',
          title: '湿度',
          align: "right",
          halign: "center"
        }, {
          field: 'PROBE.CONLIMIT',
          title: '浓度阀值',
          align: "right",
          halign: "center"
        }, {
          field: 'PROBE.PURIFIERSTATE',
          title: '净化器状态',
          align: "right",
          halign: "center",
          formatter: this.yesOrNoFormat
        }, {
          field: 'PROBE.BLOWERSTATE',
          title: '风机状态',
          align: "right",
          halign: "center",
          formatter: this.yesOrNoFormat
        }, {
          field: 'PROBE.CLEANLINESS',
          title: '洁净度',
          align: "right",
          halign: "center",
          formatter: this.yesOrNoCleanliness
        }, {
            field: 'PROBE.NUM',
            title: '编号',
            align: "right",
            halign: "center",
            visible: false
          }, {
          field: 'CREATETIME',
          title: '创建时间',
          valign: "middle",
          align: "left",
          halign: "center"
        }
        ]
      ],
      data: lampblackDatas,
      striped: true,
      undefinedText: "暂无数据",
      pagination: true,
      paginationLoop: false,
      paginationPreText: "上一页",
      paginationNextText: "下一页",
      showColumns: true,
      showExport: true,
      exportDataType: 'all', //导出类型
      buttonsAlign: "right",  //按钮位置
      exportTypes: ['excel'],  //导出文件类型
      exportOptions: {
        ignoreColumn: [0],  //根据索引忽[0,1,2]略某一列的导出数据
        fileName: '油烟数据报表',  //保存文件名称设置
        worksheetName: 'sheet1',  //表格工作区名称
        tableName: '油烟数据报表',
        excelstyles: ['background-color', 'color', 'font-size', 'font-weight'],
      },
      showRefresh: true,
      height: 711,
      toolbar: ".one-btn-crud",
      showPaginationSwitch: true,
      pageSize: 15,
      pageList: [10, 15, 20]
    });

  }

  /**
   * 表格化PH水质数据
   * @param waterDatas
   */
  private waterDataForm(waterDatas) {
    $(".one-table-area").html('<table id="one_table_monitor"></table>');
    $('#one_table_monitor').bootstrapTable({
      columns: [
        {
          field: 'SNCODE',
          title: '设备编号',
          valign: "middle",
        }, {
          field: 'MONITORTIME',
          title: '监测时间',
          valign: "middle",
          align: "left",
          halign: "center"
        }, {
          field: 'MONITORCODE',
          title: '设备类型编码',
          align: "right",
          halign: "center",
          visible: false
        }, {
          field: 'PH',
          title: 'PH',
          align: "right",
          halign: "center"
        }, {
          field: 'CREATETIME',
          title: '创建时间',
          valign: "middle",
          align: "left",
          halign: "center"
        }, {
          field: 'DATASOURCE',
          title: '数据来源',
          valign: "middle",
          align: "left",
          halign: "center",
          visible: false
        }
      ],
      data: waterDatas,
      striped: true,
      undefinedText: "暂无数据",
      showColumns: true,
      showExport: true,
      exportDataType: 'all', //导出类型
      buttonsAlign: "right",  //按钮位置
      exportTypes: ['excel'],  //导出文件类型
      exportOptions: {
        ignoreColumn: [0],  //根据索引忽[0,1,2]略某一列的导出数据
        fileName: 'PH水质数据报表',  //保存文件名称设置
        worksheetName: 'sheet1',  //表格工作区名称
        tableName: 'PH水质数据报表',
        excelstyles: ['background-color', 'color', 'font-size', 'font-weight'],
      },
      showRefresh: true,
      height: 711,
      toolbar: ".one-btn-crud",
      showPaginationSwitch: true,
      paginationPreText: "上一页",
      paginationNextText: "下一页",
      pageSize: 15,
      pageList: [10, 15, 20]
    });
  }

  /**
   * 表格化土壤数据
   * @param soilDatas
   */
  private soilDataForm(soilDatas) {
    $(".one-table-area").html('<table id="one_table_monitor"></table>');
    $('#one_table_monitor').bootstrapTable({
      columns: [
        {
          field: 'SNCODE',
          title: '设备编号',
          valign: "middle"
        },
        {
          field: 'MONITORTIME',
          title: '监测时间',
          valign: "middle",
          align: "left",
          halign: "center"
        }, {
          field: 'MONITORCODE',
          title: '设备类型',
          align: "right",
          halign: "center",
          visible: false
        }, {
          field: 'PH',
          title: 'PH',
          align: "right",
          halign: "center"
        }, {
          field: 'TEMP',
          title: '温度',
          align: "right",
          halign: "center"
        }, {
          field: 'MOISTURE',
          title: '水分',
          align: "right",
          halign: "center"
        }, {
          field: 'CONDUCTIVITY',
          title: '导电率',
          align: "right",
          halign: "center"
        }, {
          field: 'CREATETIME',
          title: '创建时间',
          valign: "middle",
          align: "left",
          halign: "center"
        }, {
          field: 'DATASOURCE',
          title: '数据来源',
          valign: "middle",
          align: "left",
          halign: "center",
          visible: false
        }
      ],
      data: soilDatas,
      striped: true,
      undefinedText: "暂无数据",
      pagination: true,
      paginationLoop: false,
      paginationPreText: "上一页",
      paginationNextText: "下一页",
      showColumns: true,
      showExport: true,
      exportDataType: 'all', //导出类型
      buttonsAlign: "right",  //按钮位置
      exportTypes: ['excel'],  //导出文件类型
      exportOptions: {
        ignoreColumn: [0],  //根据索引忽[0,1,2]略某一列的导出数据
        fileName: '土壤数据报表',  //保存文件名称设置
        worksheetName: 'sheet1',  //表格工作区名称
        tableName: '土壤数据报表',
        excelstyles: ['background-color', 'color', 'font-size', 'font-weight'],
      },
      showRefresh: true,
      height: 711,
      toolbar: ".one-btn-crud",
      showPaginationSwitch: true,
      pageSize: 15,
      pageList: [10, 15, 20]
    });
  }


  /**
   * yesOrNo格式化函数
   * @param value
   * @param row
   * @param index
   * @returns {any}
   */
  private yesOrNoFormat(value, row, index) {
    if (value == '0') {
      return "开";
    }
    if (value == '1') {
      return "关";
    }
  }

  /**
   * yesOrNo格式化函数
   * @param value
   * @param row
   * @param index
   * @returns {any}
   */
  private yesOrNoCleanliness(value, row, index) {
    if (value == '1') {
      return "清洁";
    }
    if (value == '2') {
      return "较清洁";
    }
    if (value == '3') {
      return "脏";
    }
    if (value == '4') {
      return "较脏";
    }
    if (value == '5') {
      return "极脏";
    }
  }

}







